extends Node2D
class_name FlagSwitch

export var flag :String

var default_node :Node2D
var switch_node :Node2D

func _ready():
	var cound := get_child_count()
	if cound > 0:
		default_node = get_child(0)
	if cound > 1:
		switch_node = get_child(1)
		
	_update_nodes()
	
func _update_nodes():
	var exists := Game.flags.has(flag)
	
	if default_node:
		default_node.visible = not exists
	if switch_node:
		switch_node.visible = exists
		
